//
//  UISearchBar+JCSearchBarPlaceholder.m
//  NewPro
//
//  Created by RYX on 2018/10/16.
//  Copyright © 2018年 何荧红. All rights reserved.
//

#import "UISearchBar+JCSearchBarPlaceholder.h"

@implementation UISearchBar (JCSearchBarPlaceholder)

-(void)changeLeftPlaceholder:(NSString *)placeholder {
    
    self.placeholder = placeholder;
    SEL centerSelector = NSSelectorFromString([NSString stringWithFormat:@"%@%@", @"setCenter", @"Placeholder:"]);
    
    if ([self respondsToSelector:centerSelector]) {
        
        BOOL centeredPlaceholder = NO; NSMethodSignature *signature = [[UISearchBar class] instanceMethodSignatureForSelector:centerSelector];
        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
        [invocation setTarget:self];
        [invocation setSelector:centerSelector]; [invocation setArgument:&centeredPlaceholder atIndex:2];
        [invocation invoke];
        
    }
    
}

@end
